import TreeSelect from "components/tree-select";

export default {
  components: { TreeSelect },
  data() {
    return {
      // 部门数据
      treeData: [],
    };
  },
  methods: {
    /**
     * 获取选中数据
     */
    getSelectedTreeData({
      val,
      // 0=>点击叉叉，1=>点击重置
      type = 0,
      formName = "form",
      setSelectedTreeNameFlag = false,
      selectedTreeIdKey = "orgId",
      selectedTreeNameKey = "orgName",
    }) {
      if (val) {
        let { id, name } = val;
        this[formName][selectedTreeIdKey] = id.toString();
        setSelectedTreeNameFlag && (this[formName][selectedTreeNameKey] = name);
      } else {
        this[formName][selectedTreeIdKey] = "";
        setSelectedTreeNameFlag && (this[formName][selectedTreeNameKey] = "");
      }
      // 选择完数据，根据选择的数据做其他操作
      this.otherOperate && this.otherOperate(val, type);
    },
  },
};
